Java Arrays


Tip
The main difference between arrays in C++ and Java it that you do not need to delete the array when the new command is used.
La principal diferencia entre los arreglos en C++ y Java es que usted no tiene que borrar el arreglo cuando se usa el comando new.

List.java
public class List
{
     public List()
     {
          int[] age = new int[4];
          age[0] = 14;
          age[1] = 22;
          age[2] = 45;
          age[3] = 78;
     }
};


List.java
public class List
{
     public List()
     {
          double[] weights = {1.9, 2.9, 3.4, 3.5};
     }
};


System.arrayCopy

Java provides the arrayCopy function to copy two arrays as shown below.
Java proporciona la función arrayCopy para copiar dos arreglos como se muestra debajo.

Program.java
public class Program
{
     public List()
     {
          double[] weights = {1.9, 2.9, 3.4, 3.5};
          double[] new_weigths;
          System.arrayCopy(weights, 0, new_weights, 0, weights.length);
     }
};



© Copyright 2000-2021 Wintempla selo. All Rights Reserved. Jul 22 2021. Home